<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class ServiceCity extends Model
{
    use SoftDeletes;

    protected $table = 'service_city';

    protected $casts = [
        'default_user_company_id'=> 'integer ',
        'default_driver_company_id'=> 'integer ',
    ];

    const STATUS = [
        0 => '禁用',
        1 => '启用',
    ];


    /**
     * 用户默认公司详情
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function default_user_company()
    {
        return $this->belongsTo(Company::class, 'default_user_company_id');
    }


    /**
     * 司机默认公司详情
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function default_driver_company()
    {
        return $this->belongsTo(Company::class, 'default_driver_company_id');
    }

    public static function selectOptionByPid()
    {
        return self::query()->orderBy('id')->pluck('city_name', 'id');
    }
}
